﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StyleMVVM.DependencyInjection;
using StyleMVVM.DependencyInjection.Impl;

namespace StyleMVVM.DependencyInjection
{
	/// <summary>
	/// Use this attribute on the top of a class you want to export to the DI container
	/// </summary>
	[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
	public class ExportAttribute : Attribute, IExportAttribute
	{
		/// <summary>
		/// Exports as the name of the Class with no namespace
		/// </summary>
		public ExportAttribute()
		{
		}

		/// <summary>
		///  Exports as the FullName of the Type
		/// </summary>
		/// <param name="type"></param>
		/// <param name="types"></param>
		public ExportAttribute(Type type, params Type[] types)
		{
			List<Type> exportTypes = new List<Type>();

			exportTypes.Add(type);

			if (types != null)
			{
				exportTypes.AddRange(types);
			}

			ExportTypes = exportTypes;
		}

		/// <summary>
		/// Exports the type as exportName
		/// </summary>
		/// <param name="exportName"></param>
		/// <param name="names"></param>
		public ExportAttribute(string exportName, params string[] names)
		{
			List<string> exportNames = new List<string>();

			exportNames.Add(exportName);

			if (names != null)
			{
				exportNames.AddRange(names);
			}

			ExportNames = exportNames;
		}

		/// <summary>
		/// Exported Types for this type
		/// </summary>
		public IEnumerable<Type> ExportTypes { get; set; }

		/// <summary>
		/// Exported Name for this type
		/// </summary>
		public IEnumerable<string> ExportNames { get; set; }
	}
}